// pages/my/addFeedback/addFeedback.js
var dataCut = require("../../../utils/dataCut");
var util = require("../../../utils/util");
var app = getApp();
import Toast from "../../../miniprogram_npm/@vant/weapp/toast/toast";
Page({
  /**
   * 页面的初始数据
   */
  data: {
    token:'',
    colortype: false,
    songHave: false,
    singerHave: false,
    langHave: false,
    pickValue: "国语",
    langList: ["国语", "粤语", "英语", "韩语", "日语", "其他"],
    isFullSucreen: app.globalData.isFullSucreen ? true : false, //判断机型
  },
  // 歌曲名称输入
  songInput(e) {
    console.log(e.detail.value);
    if (e.detail.value == "") {
      console.log("空");
      this.setData({
        songHave: false,
      });
    } else {
      console.log("有");
      this.setData({
        songHave: true,
      });
    }
    this.changeDisabled();
  },
  // 歌手输入
  singerInput(e) {
    console.log(e.detail.value);
    if (e.detail.value == "") {
      console.log("空");
      this.setData({
        singerHave: false,
      });
    } else {
      console.log("有");
      this.setData({
        singerHave: true,
      });
    }
    this.changeDisabled();
  },

  bindPickerChange(e) {
    console.log(e.detail.value);
    this.setData({
      pickValue: this.data.langList[e.detail.value],
      langHave: true,
    });
    this.changeDisabled();
  },

  changeDisabled() {
    if (this.data.songHave && this.data.singerHave) {
      this.setData({
        colortype: true,
      });
    } else {
      this.setData({
        colortype: false,
      });
    }
  },
  SubmitForm(e) {
    // console.log(e.detail.value);
    let that=this
    if (this.data.colortype) {
      console.log(e.detail.value);
      var params = {
        feedback_type: 1,
        song_name: e.detail.value.song,
        singer_name: e.detail.value.singer,
        // language: e.detail.value.langType,
        language: that.data.pickValue,
      };
      console.log(params)
      util.postToken("/wechat/feedback/add", params ,that.data.token, function (res) {
        console.log(res);
        if (res.status_code==200) {
          Toast.success("感谢您的反馈");
        } else {
          
        }
        
      });
    } else {
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var token = wx.getStorageSync("token");
    let that = this;
    this.setData({
      token,
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
});
